<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ExpressFeeConfig extends Model
{
    protected $guarded = [];
    public $timestamps = false;

    public function getInfo()
    {
        $unfar_express_fee = 0;
        $unfar_order_price = 0;
        $unfar_info = $this->newQuery()->where('type',1)->first();
        if(!empty($unfar_info))
        {
            $unfar_express_fee = $unfar_info->express_fee;
            $unfar_order_price = $unfar_info->order_price;
        }

        $far_express_fee = 0;
        $far_order_price = 0;
        $far_info = $this->newQuery()->where('type',2)->first();
        if(!empty($far_info))
        {
            $far_express_fee = $far_info->express_fee;
            $far_order_price = $far_info->order_price;;
        }

        $result = [
            'unfar_express_fee' => $unfar_express_fee,
            'unfar_order_price' => $unfar_order_price,
            'far_express_fee'   => $far_express_fee,
            'far_order_price'   => $far_order_price,
        ];
        return $result;
    }
}
